﻿Imports DotNetNuke
Imports DotNetNuke.Services.Exceptions
Imports NEvoWeb.Modules.NB_Store.SharedFunctions

Public Class Settings
    Inherits DnnC_Accordion_CategoryMenuSettingsBase

#Region "Base Method Implementations"


    Public Overrides Sub LoadSettings()
        Try
            If Not Page.IsPostBack Then

                populateTabsList(lstProductTabs, PortalSettings, TabId.ToString)
                If Not IsNothing(Settings("lstProductTabs")) Then
                    lstProductTabs.SelectedValue = Settings("lstProductTabs").ToString()
                End If

                populateCategoryList(PortalId, ddlDefaultCategory, "0", "<Root>", "0")
                If Not IsNothing(Settings("dnnC_defaultMenu")) Then
                    ddlDefaultCategory.SelectedValue = Settings("dnnC_defaultMenu").ToString()
                End If

                If Not IsNothing(Settings("dnnC_ShowProductCount")) Then
                    chkNumProducts.Checked = CBool(Settings("dnnC_ShowProductCount"))
                End If




                If Not IsNothing(Settings("dnnC_AccordionStyle")) Then ddlStyle.SelectedValue = Settings("dnnC_AccordionStyle").ToString()
                If Not IsNothing(Settings("dnnC_AccordionEventType")) Then ddlEvent.SelectedValue = Settings("dnnC_AccordionEventType").ToString()
                If Not IsNothing(Settings("dnnC_AccordionSpeed")) Then ddlSpeed.SelectedValue = Settings("dnnC_AccordionSpeed").ToString()


                If Not IsNothing(Settings("dnnC_AccordionHoverDelay")) Then
                    txtHoverDelay.Text = Settings("dnnC_AccordionHoverDelay").ToString
                Else
                    txtHoverDelay.Text = "100"
                End If

                If Not IsNothing(Settings("dnnC_AccordionMenuClose")) Then chkMenuClose.Checked = Settings("dnnC_AccordionMenuClose").ToString()
                If Not IsNothing(Settings("dnnC_AccordionAutoClose")) Then chkAutoClose.Checked = Settings("dnnC_AccordionAutoClose").ToString()
                If Not IsNothing(Settings("dnnC_AccordionAutoExpand")) Then chkAutoExpand.Checked = Settings("dnnC_AccordionAutoExpand").ToString()
                If Not IsNothing(Settings("dnnC_AccordionSaveState")) Then chkSaveState.Checked = Settings("dnnC_AccordionSaveState").ToString()
                If Not IsNothing(Settings("dnnC_AccordionDisableLinks")) Then chkDisableLinks.Checked = Settings("dnnC_AccordionDisableLinks").ToString()


                If Not IsNothing(Settings("dnnC_AccordionCookie")) Then
                    txtCookie.Text = Settings("dnnC_AccordionCookie").ToString
                Else
                    txtCookie.Text = "NBS_CateMenu_" & ModuleId.ToString
                End If

                If Not IsNothing(Settings("dnnC_AccordionClassParent")) Then txtClassParent.Text = Settings("dnnC_AccordionClassParent").ToString
                If Not IsNothing(Settings("dnnC_AccordionClassActive")) Then txtClassActive.Text = Settings("dnnC_AccordionClassActive").ToString
                If Not IsNothing(Settings("dnnC_AccordionClassArrow")) Then txtClassArrow.Text = Settings("dnnC_AccordionClassArrow").ToString
                If Not IsNothing(Settings("dnnC_AccordionClassExpand")) Then txtClassExpand.Text = Settings("dnnC_AccordionClassExpand").ToString







            End If
        Catch exc As Exception           'Module failed to load
            ProcessModuleLoadException(Me, exc)
        End Try
    End Sub


    Public Overrides Sub UpdateSettings()
        Try
            Dim objModules As New Entities.Modules.ModuleController
            objModules.UpdateModuleSetting(ModuleId, "lstProductTabs", lstProductTabs.SelectedValue)


            objModules.UpdateModuleSetting(ModuleId, "dnnC_defaultMenu", ddlDefaultCategory.SelectedValue)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_ShowProductCount", chkNumProducts.Checked)

            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionStyle", ddlStyle.SelectedValue)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionEventType", ddlEvent.SelectedValue)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionSpeed", ddlSpeed.SelectedValue)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionHoverDelay", txtHoverDelay.Text)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionMenuClose", chkMenuClose.Checked)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionAutoClose", chkAutoClose.Checked)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionAutoExpand", chkAutoExpand.Checked)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionSaveState", chkSaveState.Checked)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionDisableLinks", chkDisableLinks.Checked)

            If Not txtCookie.Text = String.Empty Then
                objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionCookie", txtCookie.Text)
            Else
                objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionCookie", "NBS_CateMenu_" & ModuleId.ToString)
            End If

            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionClassParent", txtClassParent.Text)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionClassActive", txtClassActive.Text)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionClassArrow", txtClassArrow.Text)
            objModules.UpdateModuleSetting(ModuleId, "dnnC_AccordionClassExpand", txtClassExpand.Text)

        Catch exc As Exception           'Module failed to load
            ProcessModuleLoadException(Me, exc)
        End Try
    End Sub

#End Region


End Class